var e = require, t = module, n = exports;

Object.defineProperty(n, "__esModule", {
    value: !0
}), n.PetModel = void 0;

var o = e("GameConfig"), i = e("GameData"), a = e("Global"), r = e("UIManager");

n.PetModel = function() {};

var s = function() {
    function t() {}
    return t.getInstance = function() {
        return this._manager || (this._manager = new t()), this._manager;
    }, t.prototype.check = function() {
        var t = this.getRealData();
        t.has && !a.G.chargeList[i.GD.petDataIdx] && t.hp / this.getHp() < .3 && (a.G.chargeList[i.GD.petDataIdx] = 1, 
        t.time = Date.now());
    }, t.prototype.updateTime = function(t, e) {
        t = Math.max(0, Math.floor(t / 1e3));
        return t >= o.GC.petChargeTime && (a.G.chargeList[i.GD.petDataIdx] = 0, e.hp = this.getHp(), 
        r.default.getInstance().petShows.forEach(function(t) {
            return t.refresh();
        })), Math.max(o.GC.petChargeTime - t, 0);
    }, t.prototype.load = function(t) {
        var e = this.getRealData();
        return e.has && a.G.chargeList[i.GD.petDataIdx] && e.time < t ? this.updateTime(t - e.time, e) : 0;
    }, t.prototype.isHas = function(t) {
        return void 0 === t && (t = i.GD.petDataIdx), this.getRealData(t).has;
    }, t.prototype.getAtk = function(t, e) {
        return void 0 === t && (t = i.GD.petDataIdx), void 0 === e && (e = this.getRealData().lv), 
        this.getConfig(t).ATK + this.getConfig(t).ATK_UP * e;
    }, t.prototype.getIdle = function(t, e) {
        return void 0 === t && (t = i.GD.petDataIdx), void 0 === e && (e = this.getRealData().lv), 
        Math.max(2, this.getConfig(t).IDLE - .1 * e);
    }, t.prototype.getHp = function(t, e) {
        return void 0 === t && (t = i.GD.petDataIdx), void 0 === e && (e = this.getRealData().lv), 
        this.getConfig(t).HP + 200 * e;
    }, t.prototype.getRealHp = function(t) {
        return void 0 === t && (t = i.GD.petDataIdx), Math.min(this.getRealData(t).hp, this.getHp(t));
    }, t.prototype.getPetIdx = function(t, e) {
        void 0 === t && (t = i.GD.petDataIdx);
        var a = this.getRealData(t);
        return 100 * t + (e = isNaN(e) || e > a.form || e < 0 ? a.form : e);
    }, t.prototype.getPetDataIdx = function(t) {
        return Math.min(Math.max(0, Math.floor(t / 100)), o.GC.petModelList.length - 1);
    }, t.prototype.setRealData = function(t, e) {
        (e = void 0 === e ? i.GD.petDataIdx : e) < i.GD.petDataList.length && (i.GD.petDataList[e] = t);
    }, t.prototype.getRealData = function(t) {
        return ((t = void 0 === t ? i.GD.petDataIdx : t) >= i.GD.petDataList.length || !i.GD.petDataList[t]) && (i.GD.petDataList[t] = {
            lv: 0,
            hp: 3200,
            form: 0,
            has: 0,
            time: 0
        }), i.GD.petDataList[t];
    }, t.prototype.getConfig = function(t) {
        return (t = void 0 === t ? i.GD.petDataIdx : t) < o.GC.petModelList.length ? o.GC.petModelList[t] : o.GC.petModelList[0];
    }, t.prototype.getSkinConfig = function(t) {
        return (t = void 0 === t ? i.GD.petDataIdx : t) < o.GC.petSkinConfigLsit.length && 0 <= t ? o.GC.petSkinConfigLsit[t] : o.GC.petSkinConfigLsit[0];
    }, t.prototype.checkPetDataIdx = function(t) {
        return 0 < o.GC.petModelList.length && 0 <= t && t < o.GC.petModelList.length ? t : 0;
    }, t._manager = null, t;
}();

n.default = s;